Python: Remove tool content returned after invocation limits - #7408
Merged
eavanvalkenburg merged 4 commits intoJul 30, 2026
Merged
Conversation
eavanvalkenburg
temporarily deployed
to
github-app-auth
July 29, 2026 20:11 — with
GitHub Actions
Inactive
eavanvalkenburg
temporarily deployed
to
github-app-auth
July 29, 2026 20:11 — with
GitHub Actions
Inactive
eavanvalkenburg
marked this pull request as ready for review
July 29, 2026 20:12
eavanvalkenburg
temporarily deployed
to
github-app-auth
July 29, 2026 20:12 — with
GitHub Actions
Inactive
Contributor
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the Python function-calling loop to prevent “orphaned” tool calls or approval requests from being surfaced to callers after the framework has intentionally disabled tool execution due to invocation limits. It aligns streaming and non-streaming behavior by filtering unexecutable tool-related content while preserving provider metadata updates and maintaining deterministic fallback behavior when no visible final content remains.
Changes:
- Drop
function_callandfunction_approval_requestcontent from finalized responses once invocation limits disable tools, before applying the existing fallback logic. - Drop the same unexecutable tool content from streaming updates (while retaining metadata-only updates when present).
- Add unit tests covering both
max_function_callsandmax_iterationsfor streaming and non-streaming paths, plus a metadata-preservation streaming case, and update specs/docs to reflect the new guarantee.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| python/packages/core/agent_framework/_tools.py | Adds filtering helpers to remove unexecutable tool content from streamed updates and final responses after invocation limits disable tools, preserving metadata-only updates and existing fallback behavior. |
| python/packages/core/tests/core/test_function_invocation_logic.py | Adds regression tests to ensure post-limit tool content is not exposed (streaming + non-streaming) and that metadata-only streaming updates remain visible after filtering. |
| python/packages/core/AGENTS.md | Documents the new behavior that post-limit provider-emitted calls/approval requests are removed while metadata-only streaming updates remain visible. |
| docs/specs/004-python-function-calling-loop.md | Updates the spec matrix to mark the #7045 scenario as covered by tests and calls out transcript integrity after limits. |
TaoChenOSU
reviewed
Jul 29, 2026
TaoChenOSU
approved these changes
Jul 29, 2026
eavanvalkenburg
temporarily deployed
to
github-app-auth
July 30, 2026 05:34 — with
GitHub Actions
Inactive
eavanvalkenburg
enabled auto-merge
July 30, 2026 05:38
eavanvalkenburg
force-pushed
the
python-function-limit-transcript-integrity
branch
from
July 30, 2026 06:59
bbb3ae2 to
c62f2b2
Compare
eavanvalkenburg
temporarily deployed
to
github-app-auth
July 30, 2026 06:59 — with
GitHub Actions
Inactive
moonbox3
reviewed
Jul 30, 2026
eavanvalkenburg
force-pushed
the
python-function-limit-transcript-integrity
branch
from
July 30, 2026 07:41
c62f2b2 to
53729a9
Compare
eavanvalkenburg
temporarily deployed
to
github-app-auth
July 30, 2026 07:41 — with
GitHub Actions
Inactive
moonbox3
approved these changes
Jul 30, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Jul 30, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1ee1d250-d1e2-4c6f-8c36-aae0d94fe7a1
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1ee1d250-d1e2-4c6f-8c36-aae0d94fe7a1
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1ee1d250-d1e2-4c6f-8c36-aae0d94fe7a1
eavanvalkenburg
enabled auto-merge
July 30, 2026 08:20
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1ee1d250-d1e2-4c6f-8c36-aae0d94fe7a1
eavanvalkenburg
force-pushed
the
python-function-limit-transcript-integrity
branch
from
July 30, 2026 08:21
53729a9 to
0ee8d9c
Compare
eavanvalkenburg
temporarily deployed
to
github-app-auth
July 30, 2026 08:21 — with
GitHub Actions
Inactive
5 tasks
5 tasks
eavanvalkenburg
temporarily deployed
to
github-app-auth
July 30, 2026 08:22 — with
GitHub Actions
Inactive
moonbox3
approved these changes
Jul 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation & Context
A provider can ignore
tool_choice="none"after an invocation limit and return another local call that the frameworkwill not execute. Exposing that content leaves callers with an unanswered function call or local approval request.
Description & Review Guide
max_function_callsormax_iterations.Related Issue
Fixes #7045
Shared spec reconciliation is in #7409, which should merge after #7407 and #7408.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.